package sicau.car.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author ITcz
 * @Data 2020-09-16 - 11:27
 * 配置管理员登录验证和用户登录验证
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public UserIntercepter addLocalIntercepter(){
        return new UserIntercepter();
    }

    @Autowired
    UserIntercepter userIntercepter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new CorsInterceptor()).addPathPatterns("/**").order(2);
        registry.addInterceptor(userIntercepter).addPathPatterns("/userCar/loginIn");
    }
}
